<?php
	require_once("class.phpmailer.php"); 				// 下载的文件必须放在该文件所在目录

	function sendEmailClass($to_arr,$title,$content,$attach_arr,$alias_arr){
		$status=0;
	
		$mail = new PHPMailer(); 							// 建立邮件发送类
		
								// 使用SMTP方式发送
		$mail->CharSet="UTF-8";	
		$mail->IsSMTP();	
		$mail->SMTPAuth = true; 
		$mail->SMTPSecure = "ssl";						// 处理中文乱码
		$mail->Host = "smtp.163.com"; 
		$mail->Port=465;						// 您的企业邮局域名
	
		$mail->Username = "keeva_mail@163.com"; 		// 邮局用户名(请填写完整的email地址)
		$mail->Password = "Springside123456"; 	
		$mail->SetFrom('KM@keeva.com', 'KM@keeva.com'); 			// 邮局密码
		$mail->AddReplyTo("KM@keeva.com","KM@keeva.com");
		
		for($jj=0;$jj<count($to_arr);$jj++){
			//if($jj==0)
				$mail->AddAddress($to_arr[$jj]);
			//else
				//$mail->addCC($to_arr[$jj]);				// 收件人地址，可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名")
		}
		$mail->IsHTML(true); 								// set email format to HTML //是否使用HTML格式
		$mail->Subject = $title;	
		$mail->AltBody = "for read, switch to html mall client"; 		 				// 邮件标题
		$mail->MsgHTML($content);  
		
		foreach($attach_arr as $k => $oa)
		{
			$mail->addAttachment($oa,$alias_arr[$k]);
		}

		//$mail->Body = $content;
		//$logger->info($mail);								// 附加信息，可以省略
		if(!$mail->Send()){
			$status=1;
		}
		writeLog(json_encode($to_arr)."-".$title."-".$mail->ErrorInfo,"info");
		$mail->SmtpClose();
		return $status;
	}

	//$mailarr=array("3029757998@qq.com","104085333@qq.com");
	
	//echo sendEmailClass($mailarr,"have Attachment","please receive files ".rand());
?>
